import { AxiosRequestConfig } from 'axios'

import * as http from '@/http'
import * as api from '@/api/cms'

/**
 * 登录
 *
 * @param {Object} params
 * @return {Promise<any>}
 */
export const login = (params: any): Promise<any> => http.post(api.login, params)

/**
 * 侧栏菜单
 *
 * @param {Object} [params] 参数
 * @return {Promise<any>}
 */
export const sidebarMenu = (params?: any): Promise<any> => http.get(api.sidebarMenu, params)

/**
 * 上传图片
 *
 * @param {Object} params 参数
 * @param {AxiosRequestConfig} [config] 请求配置
 */
export const uploadImage = (params: any, config?: AxiosRequestConfig): Promise<any> => {
  return http.uploadFile(api.uploadImage, params, config)
  // return http.uploadFile(`${api.uploadImage}/${uploadDir}`, params, config)
}

/**
 * 上传文件
 *
 * @param {Object} params 参数
 * @param {AxiosRequestConfig} [config] 请求配置
 */
export const uploadFile = (params: any, config?: AxiosRequestConfig): Promise<any> => {
  return http.uploadFile(api.uploadFile, params, config)
}
